
-include $(APPDIR)/Make.defs

ifeq ($(CONFIG_MIBLE_SDK_USE_SRC),y)
include mijia_ble_libs/Make.defs
else
EXTRA_LIBPATHS += -L src/
EXTRA_LIBS += -lmesh-auth-native-debug
endif

CFLAGS += -DCUSTOMIZED_MI_CONFIG_FILE=\"custom_mi_config.h\"

ifeq ($(CONFIG_MIBLE_SDK_LOG),y)
CFLAGS += -DMI_LOG_ENABLED=1 -DMI_ASSERT=1
endif

CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=0 -DMI_OTP_PARTITION=1
CFLAGS += -Wno-strict-prototypes -Wno-shadow -Wno-undef

# CSRCS += src/miot_spec/on_action_invoke.c
# CSRCS += src/miot_spec/on_property_request.c
# CSRCS += src/miot_spec/on_property_get.c
# CSRCS += src/miot_spec/on_property_set.c
# CSRCS += src/miot_spec/S_2_Light_doAction.c
# CSRCS += src/miot_spec/S_2_Light_doChange.c
# CSRCS += src/miot_spec/S_1_DeviceInformation_doGet.c
# CSRCS += src/miot_spec/S_2_Light_doGet.c
# CSRCS += src/miot_spec/S_2_Light_doSet.c
SRC_DIRS += src/miot_spec
SRC_DIRS += gwin
CSRCS += $(foreach dir, $(SRC_DIRS), $(wildcard $(dir)/*.c))

CSRCS += mijia_ble_api/ble.c
CSRCS += mijia_ble_api/mesh.c
CSRCS += mijia_ble_api/memory.c
CSRCS += mijia_ble_api/nvm_vela_telink.c
CSRCS += mijia_ble_api/mi_potp_0xec4d3ebdd2c1.c
CSRCS += mijia_ble_api/mible_api.c
CSRCS += mijia_ble_api/mible_mcu.c
CSRCS += mijia_ble_api/mible_mesh_api.c

CSRCS += mijia_ble_libs/mi_config.c
CSRCS += mijia_ble_libs/third_party/pt/pt_misc.c

CSRCS += mijia_ble_libs/third_party/mbedtls/ccm.c
CSRCS += mijia_ble_libs/third_party/mbedtls/sha256_hkdf.c
CSRCS += mijia_ble_libs/third_party/mbedtls/md.c
CSRCS += mijia_ble_libs/third_party/mbedtls/md_wrap.c
CSRCS += mijia_ble_libs/third_party/mbedtls/sha256.c
CSRCS += mijia_ble_libs/third_party/mbedtls/asn1parse.c
CSRCS += mijia_ble_libs/third_party/mbedtls/base64.c

CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/external/zblue/port/include}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/external/zblue/port/include/kernel/include}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/external/zblue/include/zephyr}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/external/tinycrypt/lib/include}

CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" inc}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" mijia_ble_api}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" mijia_ble_libs}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" mijia_ble_libs/mijia_profiles}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" mijia_ble_libs/mesh_auth}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" mijia_ble_libs/third_party/micro-ecc/}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" src/miot_spec}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" gwin}

PROGNAME += mimesh
MAINSRC  += src/main.c

PRIORITY  = SCHED_PRIORITY_DEFAULT
STACKSIZE = CONFIG_MIBLE_SDK_STACK_SIZE
MODULE    = y

include $(APPDIR)/Application.mk
